# # pages/login_page.py
# from selenium.webdriver import ActionChains
# from selenium.webdriver.remote.webdriver import WebDriver
# from selenium.webdriver.support.wait import WebDriverWait
# from selenium.webdriver.support import expected_conditions as EC
# from core.base_page import BasePage  # 假设基础页面类
#
#
# class LoginPage(BasePage):
#     def __init__(self, driver: WebDriver):
#         super().__init__(driver)
#         self.driver = driver
#         self.wait = WebDriverWait(driver, 10)  # 显式等待器
#
#     # 元素定位（使用描述符简化调用）
#     @property
#     def username_input(self):
#         return self.wait.until(EC.visibility_of_element_located(
#             ("id", "username")  # 假设用户名输入框id为username
#         ))
#
#     @property
#     def password_input(self):
#         return self.wait.until(EC.visibility_of_element_located(
#             ("id", "password")  # 假设密码输入框id为password
#         ))
#
#     @property
#     def login_btn(self):
#         return self.wait.until(EC.element_to_be_clickable(
#             ("id", "loginBtn")  # 假设登录按钮id为loginBtn
#         ))
#
#     @property
#     def slider(self):
#         return self.wait.until(EC.visibility_of_element_located(
#             ("id", "slider")  # 滑块元素id
#         ))
#
#     @property
#     def slider_track(self):
#         return self.wait.until(EC.visibility_of_element_located(
#             ("id", "sliderTrack")  # 滑块轨道id
#         ))
#
#     @property
#     def toast_msg(self):
#         return self.wait.until(EC.visibility_of_element_located(
#             ("class name", "toast")  # 假设Toast元素class为toast
#         ))
#
#     # 操作方法
#     def input_username(self, username: str):
#         """输入用户名"""
#         self.username_input.clear()
#         self.username_input.send_keys(username)
#
#     def input_password(self, password: str):
#         """输入密码"""
#         self.password_input.clear()
#         self.password_input.send_keys(password)
#
#     def drag_slider(self):
#         """拖拽滑块验证（假设从左到右拖动）"""
#         slider = self.slider
#         track = self.slider_track
#         # 获取轨道长度（计算拖拽距离）
#         track_width = track.size["width"]
#         # 执行拖拽操作
#         ActionChains(self.driver)\
#             .click_and_hold(slider)\
#             .move_by_offset(track_width, 0)\
#             .release()\
#             .perform()
#         # 等待滑块验证完成（根据实际场景调整）
#         WebDriverWait(self.driver, 5).until(
#             lambda d: "验证成功" in track.text
#         )
#
#     def click_login(self):
#         """点击登录按钮"""
#         self.login_btn.click()